package com.qipay.order.service;


import com.qipay.baas.model.Order;
import com.qipay.order.vo.*;
import com.qipay.scalar.type.ChannelTypeEnum;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Creator: Yao
 * Date:    2017/9/21
 * For:
 * Other:
 */
public interface OrderService {
    //根据cpid，从订单表计算出这个商户总共多少钱
    Long sumOrderByCp(Long cpId);


    //***********************************以下是商户提现模块改之前的
    String createOrder();
    int randomDecrease(int max);

    String createOrder(int length);
    OrderSumVo sumOrder(String querysql);
    long countBy(String querysql);

    long amountCount(String querysql);
    long feeCount(String querysql);

    List<OrderListItem> listBy(String querysql,Object offset,Object rowss);

    //根据商户号查询
    List<CpTjVo> listCp0Tj(String from,String to,Long cpid);

    List<SpTjVo> listSp0Tj(String from,String to,Long spid);

    List<ChannelTjVo> listChannel0Tj(String from,String to,int channelid);

    List<ChannelSpTjVo> listChannelSp0Tj(String from,String to,String spid,int channelid);

    List<Cp_SpTjVo> listCp_Sp0Tj(String from,String to,String  cpid,int channelid);

    Order get(Long id);

    Order update(Order order);

    @Transactional
    boolean modify(Order order);

    Order insert(Order order);

    Order getByCpidAndOutTradeNo(Long cpid, String outTradeNo);

    @Transactional
    Order getByCpidAndTradeNo(Long cpid, String tradeNo);

    @Transactional
    Order getBySpMchIdAndSpTradeNo(String spMchid, String spTradeNo);

    @Transactional
    Order getByTradeNo(String tradeNo);

    Order setOrderSuccess(String tradeNo);

    @Transactional
    Order setOrderSuccess(Long orderId, String spTradeNo) throws IOException;

    @Transactional
    Order setOrderSuccess(Order order, String spTradeNo) throws IOException;

    Order setOrderFail(String tradeNo);

    List<Order> getOrderFinishTimeLargeThenOneDay(int count, int page);

    @Transactional
    Integer getOrderFinishTimeLargeThenOneDay();

    @Transactional
    Order setOrderClose(Order order);

    @Transactional
    Order selectASp(Order order, ChannelTypeEnum channelTypeEnum);

    Order selectASp(Order order, ChannelTypeEnum channelTypeEnum,List<Long>spIds);

    List<Order> statementBy(Long cpId, String from, String to, Integer channel);

    List<OrderStatementVo> statementAllBy(String from, String to, Long cpId, String cpName, Long agentId, String contract, Integer channel);

    List<OrderSpStatementVo> statementSpBy(String from, String to, Long spId, String spName, String service, Integer channel);
    Order byState(Byte state);
}
